
package com.zhangfei.selector;

import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;


@Component
public class PayHandlerSelector {

    @Resource
    private List<PayHandler> list;

    /**
     * 选择付款处理器
     */
    public PayHandler select(PayTypeEnum payTypeEnum) {
        for (PayHandler handler : list) {
            if (Objects.equals(payTypeEnum.getValue(), handler.getPayTypeEnum().getValue())) {
                return handler;
            }
        }

        return null;
    }

}

